#ifndef NCDGUI_SERVERINTERFACE_H
#define NCDGUI_SERVERINTERFACE_H

#include <base/DebugObject.h>
#include <structure/LinkedList1.h>
#include <ncd/NCDRequestClient.h>
#include <misc/debug.h>

typedef void (*ServerUser_handler_up) (void *user, NCDRequestClient *client);
typedef void (*ServerUser_func_down) (void *user);

typedef struct {
    struct NCDRequestClient_addr addr;
    BReactor *reactor;
    LinkedList1 users_list;
    BTimer timer;
    NCDRequestClient client;
    int state;
    DebugObject d_obj;
} ServerInterface;

typedef struct {
    ServerInterface *iface;
    void *user;
    ServerUser_handler_up handler_up;
    ServerUser_func_down func_down;
    LinkedList1Node users_list_node;
    BPending up_job;
    int reported_up;
    DebugObject d_obj;
} ServerUser;

int ServerInterface_Init (ServerInterface *o, struct NCDRequestClient_addr addr, BReactor *reactor) WARN_UNUSED;
void ServerInterface_Free (ServerInterface *o);

void ServerUser_Init (ServerUser *o, ServerInterface *iface, void *user, ServerUser_handler_up handler_up, ServerUser_func_down func_down);
void ServerUser_Free (ServerUser *o);

#endif
